﻿// 功能：弹出表格式菜单项
// 描述：
// 作者：温伟鹏
// 日期：2010/5/13 16:53:59

using System;
using MeizuSDK.Drawing;

namespace MeizuSDK.Presentation
{
    /// <summary>
    /// 弹出表格式菜单项
    /// </summary>
    public class GridMenuItem
    {
        #region 私有变量
        private GridMenu owner;
        private int itemId;
        private string itemText;
        private bool enabled;
        private ImagingHelper itemImg;
        private ImagingHelper itemImgPressed;
        #endregion

        #region 公共属性
        /// <summary>
        /// 获取菜单项所属的弹出菜单
        /// </summary>
        public GridMenu Owner
        {
            get
            {
                return this.owner;
            }
            internal set
            {
                this.owner = value;
            }
        }
        /// <summary>
        /// 获取或设置菜单项的编号
        /// </summary>
        public int ItemId
        {
            get
            {
                return this.itemId;
            }
            set
            {
                if (value != this.itemId)
                {
                    this.itemId = value;
                }
            }
        }
        /// <summary>
        /// 获取或设置菜单项显示的文本
        /// </summary>
        public string Text
        {
            get
            {
                return this.itemText;
            }
            set
            {
                if (value != this.itemText)
                {
                    this.itemText = value;

                    if (Owner != null)
                    {
                        Owner.ModifyMenuItem(ItemId, value, ItemImage, ItemImagePressed);
                    }
                }
            }
        }
        /// <summary>
        /// 获取或设置菜单项图像
        /// </summary>
        public ImagingHelper ItemImage
        {
            get
            {
                return this.itemImg;
            }
            set
            {
                if (value != this.itemImg)
                {
                    this.itemImg = value;
                    if (Owner != null)
                    {
                        Owner.ModifyMenuItem(ItemId, Text, value, ItemImagePressed);
                    }
                }
            }
        }
        /// <summary>
        /// 获取或设置菜单项被按下后显示的图像
        /// </summary>
        public ImagingHelper ItemImagePressed
        {
            get
            {
                return this.itemImgPressed;
            }
            set
            {
                if (value != this.itemImgPressed)
                {
                    this.itemImgPressed = value;
                    if (Owner != null)
                    {
                        Owner.ModifyMenuItem(ItemId, Text, ItemImage, value);
                    }
                }
            }
        }
        /// <summary>
        /// 获取或设置一个值，指示此菜单项是否被启用
        /// </summary>
        public bool Enabled
        {
            get
            {
                return this.enabled;
            }
            set
            {
                if (value != this.enabled)
                {
                    this.enabled = value;
                    if (Owner != null)
                    {
                        Owner.EnableMenuItem(ItemId, value);
                    }
                }
            }
        }
        #endregion

        #region 构造函数
        /// <summary>
        /// 构造弹出表格式菜单项
        /// </summary>
        /// <param name="text">菜单项文本</param>
        public GridMenuItem(string text)
            :this(IDGenerator.NewID(),text)
        {

        }
        /// <summary>
        /// 构造弹出表格式菜单项
        /// </summary>
        /// <param name="id">菜单项Id</param>
        /// <param name="text">菜单项文本</param>
        public GridMenuItem(int id, string text)
            : this(id, text, null, null)
        {

        }
        /// <summary>
        /// 构造弹出表格式菜单项
        /// </summary>
        /// <param name="text">菜单项文本</param>
        /// <param name="img">菜单项图标</param>
        /// <param name="imgPressed">菜单项被按下时显示的图标</param>
        public GridMenuItem(string text,ImagingHelper img,ImagingHelper imgPressed)
            :this(IDGenerator.NewID(),text,img,imgPressed)
        {

        }
        /// <summary>
        /// 构造弹出表格式菜单项
        /// </summary>
        /// <param name="id">菜单项Id</param>
        /// <param name="text">菜单项文本</param>
        /// <param name="img">菜单项图标</param>
        /// <param name="imgPressed">菜单项被按下时显示的图标</param>
        public GridMenuItem(int id, string text, ImagingHelper img, ImagingHelper imgPressed)
        {
            this.itemId = id;
            this.itemText = text;
            this.itemImg = img;
            this.itemImgPressed = imgPressed;
        }
        #endregion
    }
}
